package it.blueocean.acanto.platform.web;

import java.util.ArrayList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class MainController
{
	private final static Logger logger = LoggerFactory.getLogger(MainController.class);
	
	@RequestMapping(method = RequestMethod.GET, value = "/index.htm")
	public String getIndexPage()
	{
		logger.info("invoked index.htm");
		return "home.htm";
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/home.htm")
	@Secured("ROLE_USER")
	public String getHomePage()
	{
		logger.info("invoked home.htm");
		return "secure/index";
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/administration.htm")
	@Secured("ROLE_ADMINISTRATOR")
	public ModelAndView administrationView()
	{
		logger.info("invoked ultrasecure.htm");
		ModelAndView mav = new ModelAndView("secure/extreme/index");
		mav.addObject("enabledPeople", new ArrayList<String>());
		mav.addObject("disabledPeople", new ArrayList<String>());
		
		return mav;
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/caching.htm")
	@Secured("ROLE_ADMINISTRATOR")
	public String cachingView()
	{
		logger.info("invoked caching.htm");
		return "secure/extreme/caching";
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/page1.htm")
	@Secured("ROLE_USER")
	public String getPage1()
	{
		logger.info("invoked page1.htm");
		return "secure/page1";
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/page2.htm")
	@Secured("ROLE_USER")
	public String getPage2()
	{
		logger.info("invoked page2.htm");
		return "secure/page2";
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/page3.htm")
	@Secured("ROLE_USER")
	public String getPage3()
	{
		logger.info("invoked page3.htm");
		return "secure/page3";
	}
	
}
